import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
import Layout from '@/layout'
export const constantRoutes = [
  
  {
    path: '/',
    component: Layout,
    redirect: '/home',
    children: [
      {
        path: '/',
        component: () => import('@/views/home/index'),
        name: 'Home',
      }
    ]
  },
  {
    path: '/basicsearch',
    component: Layout,
    children: [
      {
        path: '/',
        component: () => import('@/views/basicsearch/index'),
        name: 'Basicsearch',
      },{
        path: 'detail',
        component: () => import('@/views/basicsearch/detail'),
        name: 'BasicsearchDetail',
      },{
        path: 'advanced',
        component: () => import('@/views/basicsearch/advanced'),
        name: 'BasicsearchAdvanced',
      }
    ]
  },
  {
    path: '/notice',
    component: Layout,
    children: [
      {
        path: '/',
        component: () => import('@/views/notice/index'),
        name: 'Notice',
      },{
        path: 'detail',
        component: () => import('@/views/notice/detail'),
        name: 'NoticeDetail',
      }
    ]
  },
  {
    path: '/trends',
    component: Layout,
    children: [
      {
        path: '/',
        component: () => import('@/views/trends/index'),
        name: 'Trends',
      }
    ]
  },
  {
    path: '/plan',
    component: Layout,
    children: [
      {
        path: '/',
        component: () => import('@/views/plan/index'),
        name: 'Plan',
      },{
        path: 'detail',
        component: () => import('@/views/plan/detail'),
        name: 'PlanDetail',
      }
    ]
  },
  {
    path: '/pdf',
    name:'Pdf',
    component: () => import('@/views/pdf/index'),
  },
  {
    path: '/payment',
    name:'Payment',
    component: () => import('@/views/payment/index'),
  },
  {
    path: '/auth-redirect',
    component: () => import('@/views/login/auth-redirect'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/error-page/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/error-page/401'),
    hidden: true
  },
  {
    path: '/icon',
    component: Layout,
    children: [
      {
        path: 'index',
        component: () => import('@/views/icons/index'),
        name: 'Icons',
        meta: { title: 'Icons', icon: 'icon', noCache: true }
      }
    ]
  },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
  },
  {
    path: '/register',
    component: () => import('@/views/register/index'),
  },
  {
    path: '*',
    redirect: '/404',
    hidden: true
  },
]

export const asyncRoutes = [
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
